<?php
namespace Home\Controller;
use Common\Controller\HomebaseController;
/*
*  文章详情阅读 
*/
class ArticleController extends HomebaseController 
{
    protected $typeObj;
    protected $articleObj;
    public function _initialize()
    {
        parent::_initialize();
        $this->typeObj = M("Type");
        $this->articleObj = D("Content/article");
    }
    public function index()
    {
        $articleParam= I('get.article','','htmlspecialchars');
        if (is_numeric($articleParam)) {
            $where['id']=$articleParam;
        }else{
            $where['url']=$articleParam;
        }
        $where["status"]=$this->status;
        $articleObj = $this->articleObj->relation(true)->where($where)->find();
    	if(!empty($articleObj)){
            $typeId=$articleObj['typeid'];
			$this->assign('article',$articleObj);
        	$tpl=$articleObj['template'];
            $type=$this->typeObj->field('id,name')->find($typeId);
            $this->assign('type',$type);
        	$this->display($this->lang.':article:'.$tpl);
    	}else{
    	   $this->display("404");
        }
    }
    
}
?>